package com.danny.demo.single.CheckThreadSafe;

import com.danny.demo.single.signle_model.SingleObject;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @ClassName: CheckThreadSafe
 * @Description: 检测线程不安全的懒汉式
 * @Author: zhangdong
 * @Date: Created in 10:37 2019/6/26
 * @Version:
 */
public class CheckThreadSafe {
    public static void main(String[] args) {
        ExecutorService threadpool = Executors.newFixedThreadPool(20);

        for (int i = 0;i < 20;i++){
            threadpool.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+":" + SingleObject.getInstance());
                }
            });
        }
    }
}
